// ==UserScript==
// @name         PMS系统通告自动签收
// @namespace    05info
// @version      0.2
// @description  PMS系统通告自动签收!第一个
// @author       yym
// @match        http://pms.05info.com/index.php?m=my&f=indexlw
// @icon         http://pms.05info.com:88/favicon.ico
// @unrequire      https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    // 找到公告通知面板
    var ggtzPanel = $('.panel').filter(function () {
        return $(this).find('.panel-title').text().includes('公告通知')
    });

    var unsignList = ggtzPanel.find('tr').filter(function () {
        return $(this).find('.green.hide').length;
    });

    if (unsignList.length) {
        var userConfirm = confirm(`您有${unsignList.length}条未签收的公告通知，是否立即签收`);
        if (userConfirm) {
            unsignList.each(function () {
                // 获取通知公告的ID
                var url = $(this).find('a').attr('url');
                $.ajax({
                    url: url,
                    method: 'POST',
                    contentType: 'application/x-www-form-urlencoded',
                    data: {needqs: 1},
                    success: function (res) {
                        console.log(res);
                    }
                })
            });
            var refreshConfirm = confirm('已签收, 是否刷新此页面？');
            if (refreshConfirm) {
                location.reload();
            }
        }
    } else {
        console.log('没有未签收的公告');
    }


})();

